<?php

use think\migration\Seeder;

class Advert extends Seeder
{
    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * http://docs.phinx.org/en/latest/seeding.html
     */
    public function run()
    {
        // faker默认语言是英文会生成英文的数据，在创建实例的时候可以指定为中文
        $faker = Faker\Factory::create('zh_CN');
        $data = [];
        // 循环生成50条数据
        for ($i = 0; $i < 50; $i++) {
            $data[] = [
                'title'      => $faker->title(100),
                'content'      => $faker->realText,
                'link'         => $faker->url,
                'photo_link'   => "http://placeimg.com/1000/1000",
                'page_view'       => $faker->numberBetween(1,2333),
                'init_view'       => $faker->numberBetween(1,2333),
                'max_capacity'     => $faker->numberBetween(5,2333),
                'place'        => $faker->numberBetween(1,2),
                'publish'      => $faker->numberBetween(0,1,2),
                'create_time'  => time(),
            ];
        }
        \think\Db::name('advert')->insertAll($data);
    }
}